package com.txts.road.app.event.controller;

import com.txts.road.app.event.model.vo.EventRegistrationVO;
import com.txts.road.app.event.service.EventRegistrationService;
import com.txts.base.common.domain.ResponseDTO;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.txts.road.app.event.model.dto.EventRegistrationDTO;

import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;


/**
 * 赛事报名前端控制层
 *
 * @author baoyr
 * @since 2025-07-17 10:46
 */
@Tag(name = "赛事报名接口")
@RestController
@RequestMapping("/api/v1/event-registration")
@RequiredArgsConstructor
public class EventRegistrationController {
    private final EventRegistrationService eventRegistrationService;

    /**
     * 赛事报名
     */
    @Operation(summary = "赛事报名")
    @PostMapping("/{eventId}/register")
    public ResponseDTO<Boolean> registerEvent(@PathVariable Long eventId, @RequestBody EventRegistrationDTO registrationDTO) {
        return ResponseDTO.ok(eventRegistrationService.registerEvent(eventId, registrationDTO));
    }

    /**
     * 取消报名
     */
    @Operation(summary = "取消报名")
    @DeleteMapping("/{eventId}/register")
    public ResponseDTO<Boolean> cancelRegistration(@PathVariable Long eventId) {
        return ResponseDTO.ok(eventRegistrationService.cancelRegistration(eventId));
    }

    /**
     * 获取报名信息
     */
    @Operation(summary = "获取报名信息")
    @GetMapping("/{eventId}/registration")
    public ResponseDTO<EventRegistrationVO> getRegistrationInfo(@PathVariable Long eventId) {
        return ResponseDTO.ok(eventRegistrationService.getRegistrationInfo(eventId));
    }

}
